package com.itcast.peft.mapper;

import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.apache.ibatis.annotations.Mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itcast.peft.entity.Answer;

@Mapper
public interface AnswerMapper extends BaseMapper<Answer> {

    public default Map<Long, Answer> questionId2dataByGroup(String group) {
        LambdaQueryWrapper<Answer> wp = new LambdaQueryWrapper<>();
        wp.eq(Answer::getModelGroup, group);
        return this.selectList(wp).stream().collect(Collectors.toMap(Answer::getQuestionId, Function.identity()));
    }

}